import {
  getCount,
 } from './services';

export default {
  namespace: 'home',
  state: {
      count:null,
  },
  effects: {
    *fetchCount({ payload }, { call, put }) {
      const response = yield call(getCount, payload);
      //console.log(response)
      const { code, data } = response
      if(code === 1){
        yield put({
          type: 'saveCount',
          payload: data,
        });
      }
    },
  },
  reducers: {
    saveCount(state, { payload }) {
      state.count = payload
      return state
    },
  },
};
